package model.posterminal.posterminalmodel;

import java.util.ArrayList;

import model.ConfigData;
import model.address.Address;
import model.database.CallStatus;
import model.database.ObjectDataProvider;

import org.simpleframework.xml.*;

/**
 * Class describes posterminal model
 * @author Potseluev
 *
 */
@Root(name = "posterminalmodel")
public class PosTerminalModel  extends ObjectDataProvider{
	
	@Attribute(name = "id")
	long id 	= ConfigData.NOVALUELONG;
	
	@Element(name = "posterminalmodelname")
	String posTerminalModelName;

	/**
	 * Get id of posterminal model
	 * @return
	 */
	public long getId() {
		return id;
	}
	
	/**
	 * Get posterminal model
	 * @return
	 */
	public String getNamePosTerminalModel() {
		return posTerminalModelName;
	}

	/**
	 * Set posterminal model
	 * @param namePosTerminalModel
	 */
	public void setNamePosTerminalModel(String namePosTerminalModel) {
		this.posTerminalModelName = namePosTerminalModel;
	}
	
	/**
	 * Save object in database
	 * @throws Exception
	 */
	public void Save() throws Exception {
		String storeProcedureName = "posTerminalModelSave";
		
		if (this.id == ConfigData.NOVALUELONG) {
			this.id = ((PosTerminalModel) this.sendObject2GetObject(this, this.getClass(), storeProcedureName)).getId();
		}
		else {
			this.sendObject2GetObject(this, this.getClass(), storeProcedureName);
		}
		
	}
	
	/**
	 * Load all exist PosTerminalModel
	 * @return
	 * @throws Exception
	 */
	public ArrayList<PosTerminalModel> getAllPosTerminalModel() throws Exception {
		String storedProcedureName = "posTerminalModelListLoad";
		ArrayList<PosTerminalModel> result = new ArrayList<PosTerminalModel>();

		result = (ArrayList<PosTerminalModel>) this.sendObject2GetListObject(this, this.getClass(), storedProcedureName);
		
		return result;
	}
	
	
}
